package com.trigram.config;

import com.github.pagehelper.PageInterceptor;
import java.util.Properties;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisConfig {

  @Bean
  public ConfigurationCustomizer mybatisConfigurationCustomizer() {

    return configuration -> {
      final PageInterceptor interceptor = new PageInterceptor();
      final Properties      properties  = new Properties();
      properties.setProperty("helperDialect", "oracle");
      properties.setProperty("supportMethodsArguments", "true");
      interceptor.setProperties(properties);
      configuration.addInterceptor(interceptor);
    };
  }

}
